package com.zr.lads.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.zr.lads.dao.OrderDao;
import com.zr.lads.pojo.Uorder;
import com.zr.lads.pojo.User;
import com.zr.lads.service.OrderService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;

/**
 * 订单服务实现类
 * @author Windy--Chow
 *
 */
@Repository(value="orderService")
public class OrderServiceImpl implements OrderService{
       
	
	@Resource
	private OrderDao<Uorder> orderDao;
	
	@Override
	public JSONObject selectAllOrders(int page, int rows) {
		// TODO Auto-generated method stub
		JSONObject orders = new JSONObject();
		int ucount = orderDao.findAllOrdersCount();
		orders.put("total", ucount);
		List<Uorder> ordermsg = orderDao.findAllOrders(page, rows);
		JsonConfig   cfg = new JsonConfig();
		cfg.setExcludes(new String[]{"user"});
		JSONArray oo = JSONArray.fromObject(orders,cfg);
		orders.put("rows", JSONArray.fromObject(ordermsg,cfg));
		return orders;
		
	}
 
}
